package map;

import java.sql.*;

public class ConfigDAO {
    private static String URL, USU, PWD;
    private static final String ODBC_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
    
    public java.sql.Connection GetConnection() {
        try {
           return java.sql.DriverManager.getConnection(URL,USU,PWD);
         } catch( java.sql.SQLException e ) { 
           return null;
        }
    }
    
    public PreparedStatement GetPrepareStatement(String sentencia)
    {
		Connection con = GetConnection();
		PreparedStatement pstmt = null;
		try {
			pstmt = con.prepareStatement(sentencia);
     	} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return pstmt;
    }
    
    public CallableStatement GetPrepareCall(String spName)
    {
		Connection con = GetConnection();
		CallableStatement cstmt = null;
		try {
			cstmt = con.prepareCall(spName);
     	} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return cstmt;
    }
    
    public static void LoadDriverOdbc() {
        try {
            Class.forName(ODBC_DRIVER);
        } catch( ClassNotFoundException e ) { }
    }    
    
    public static void SetConnectionString() {
    	URL = "jdbc:odbc:pubs";
    	USU = "pubs";
    	PWD = "pubs";
    }
}
